Skip to content

fix(apps): give the account api key only to workers that call resources - #628

Draft
justinwlin wants to merge 1 commit into
mainfrom
fix/scope-worker-api-key
Draft

justinwlin wants to merge 1 commit into
mainfrom
fix/scope-worker-api-key

Conversation

@justinwlin

@justinwlin justinwlin commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Flash → SDK 2.0 fix stack

Independent PRs off main; merge in this order. Status: each PR's own badge.

# PR Fixes Needs
1 #627 CI: e2e fails on main (runpod-flash sunset warning) nothing; merge first so the others go green
2 #623 GPU crash loop: torch pulled in by peft/accelerate gets bundled #627 for green CI
3 #624 Workers land on GPUs you didn't request (whole pools) #627 for green CI
4 #625 rp flash dev leaks endpoints when stopped by a signal #627 for green CI
5 #626 vol.path says "not mounted" on deployed workers #627 for green CI
6 👉 #628 (this PR) Account API key copied into every endpoint #627 for green CI
7 — Release runpod 2.0.0rc2 with 1–6 1–6 merged
8 runpod-workers/sdk-runtime#1 Rebuild runtime images (dev sessions run an old SDK) independent
9 runpod/runpod-plugins-official#89 Plugin docs for the fixed SDK + VolumeCache 2.0.0rc2 on PyPI

rp flash deploy and rp flash dev copy the account API key into every endpoint's template env. Workers that never call another resource still hold full account credentials, and so does anyone who can read the template. runpod-flash injected the key only for endpoints that make remote calls.

Change

New runpod/apps/remote_calls.py. For each resource it parses the module source, walks the resource body (skipping decorators, so @runpod.post doesn't count) and the module-level helpers it reaches. It gives the key when that code:

  • references another resource, or calls .remote / .spawn
  • uses anything imported from runpod (for example runpod.Queue(...))
  • uses a project-local import it can't follow

Unreadable source and nested definitions also get the key. Every uncertain case gives the key, so a worker that needs it never goes without. Deploy and dev payloads both use the analysis. Redeploying rewrites the template env, which drops a key left by an earlier deploy.

Verification
  • Live deploy of a leaf queue plus a caller queue that runs leaf.remote(). The templates showed caller with RUNPOD_API_KEY and leaf without it. Calling caller returned {'has_key': True, 'nested': {'has_key': False, 'x': 42}}, so the nested call still works. The app was deleted afterward.
  • Unit tests classify a direct call, a call through a helper, a runpod.Queue client, an API class with only decorators, a local import, and a nested definition. They also check the deploy and dev payload env. pytest tests: 1484 passed, coverage 91.61%.

Deploy and dev copied the client's account API key into every
endpoint's template env, so any endpoint's workers (and anyone who
can read its template) held full account credentials, including
endpoints that never call another resource. runpod-flash injected the
key only for endpoints whose functions make remote calls.

Analyze each resource's module source: the resource body (not its
decorators) and the module-level helpers it reaches. The key is added
when that code references another resource, calls .remote or .spawn,
uses anything imported from runpod, or uses a project-local import the
analysis cannot follow. Unreadable source and nested definitions also
get the key, so a worker that needs it never goes without.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant